﻿// CheckProjectLibraryDialog.cpp: 实现文件
//

#include "stdafx.h"
#include "zChecker.h"
#include "CheckProjectLibraryDialog.h"
#include "afxdialogex.h"


// CCheckProjectLibraryDialog 对话框

IMPLEMENT_DYNAMIC(CCheckProjectLibraryDialog, CDialogEx)

CCheckProjectLibraryDialog::CCheckProjectLibraryDialog(CWnd* pParent /*=nullptr*/)
	: CDialogEx(IDD_DIALOG_CHECK_PROJECT_LIBRARY, pParent)
{
	m_pFrameWnd = NULL;
}

CCheckProjectLibraryDialog::~CCheckProjectLibraryDialog()
{
}

void CCheckProjectLibraryDialog::DoDataExchange(CDataExchange* pDX)
{
	CDialogEx::DoDataExchange(pDX);
}


BEGIN_MESSAGE_MAP(CCheckProjectLibraryDialog, CDialogEx)
	ON_WM_SIZE()
END_MESSAGE_MAP()


// CCheckProjectLibraryDialog 消息处理程序


BOOL CCheckProjectLibraryDialog::OnInitDialog()
{
	CDialogEx::OnInitDialog();

	// TODO:  在此添加额外的初始化
	CRect rect;
	GetClientRect(&rect);

	CString strMyClass = AfxRegisterWndClass(CS_VREDRAW | CS_HREDRAW,
		::LoadCursor(NULL, IDC_ARROW),
		(HBRUSH)::GetStockObject(WHITE_BRUSH),
		::LoadIcon(NULL, IDI_APPLICATION));

	m_pFrameWnd = new CFrameWnd();
	m_pFrameWnd->Create(strMyClass, _T(""), WS_CHILD, CRect(0, 0, 100, 100), this);
	m_pFrameWnd->MoveWindow(0, 0, 500, 400);
	m_pFrameWnd->ShowWindow(SW_SHOW);

	m_wndSplitter.Create(m_pFrameWnd);

	AdjustLayout();

	//由于非Document/View结构，系统不会调用OnInitializeUpate函数
	//无法在FormView上的控件完成初始化后对其进行调整
	//因此，手动发送WM_INITIALUPDATE，令FormView调用OnInitializeUpdate函数。
	::SendMessage(m_wndSplitter.GetPane(0, 0)->GetSafeHwnd(), WM_INITIALUPDATE, NULL, NULL);
	::SendMessage(m_wndSplitter.GetPane(0, 1)->GetSafeHwnd(), WM_INITIALUPDATE, NULL, NULL);

	m_wndSplitter.Populate();

	ShowWindow(SW_MAXIMIZE);

	return TRUE;  // return TRUE unless you set the focus to a control
				  // 异常: OCX 属性页应返回 FALSE
}


void CCheckProjectLibraryDialog::AdjustLayout()
{
	int margin = GetSystemMetrics(SM_CXFRAME);

	if (m_pFrameWnd)
	{
		CRect wndRect;
		GetWindowRect(&wndRect);
		ScreenToClient(wndRect);

		int margin = abs(wndRect.left);

		wndRect.left = margin;
		wndRect.top = 0;//nHeight;
		wndRect.right -= (2 * margin);
		wndRect.bottom -= (2 * margin);
		m_pFrameWnd->MoveWindow(wndRect);
	}
}

void CCheckProjectLibraryDialog::OnSize(UINT nType, int cx, int cy)
{
	CDialogEx::OnSize(nType, cx, cy);

	// TODO: 在此处添加消息处理程序代码
	AdjustLayout();
}
